package com.yami.shop.service.impl;

import com.yami.shop.service.MeltCloudUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ArticleCommentServiceImpl  {

    @Autowired
    private MeltCloudUserService userService;
//
//    /**
//     * 某个文章的评论列表
//     *
//     * @param articleId
//     * @return
//     */
//    @Override
//    public List<ArticleCommentVo> getCommentTrees(Long articleId) {
//        LambdaQueryWrapper<ArticleComment> queryWrapper = new LambdaQueryWrapper<ArticleComment>()
//                .eq(ArticleComment::getStatus, "0")
//                .eq(ArticleComment::getDelFlag, "0")
//                .eq(ObjectUtil.isNotEmpty(articleId), ArticleComment::getArticleId, articleId);
//        List<ArticleComment> list = this.list(queryWrapper);
//        List<Tree<String>> trees = TreeUtil.build(list, "0", (treeNode, tree) -> {
//            tree.setId(String.valueOf(treeNode.getId()));
//            tree.setParentId(String.valueOf(treeNode.getParentId()));
//            tree.setWeight(treeNode.getSort());
//            tree.setName(treeNode.getContent());
//            tree.putExtra("content", treeNode.getContent());
//        });
//        JSONArray objects = JSONUtil.parseArray(trees);
//        List<ArticleCommentVo> sysMenuTreeEntities = objects.toList(ArticleCommentVo.class);
//        return sysMenuTreeEntities;
//    }
//
//    /**
//     * 获取当前登录人的评论
//     *
//     * @param userId
//     * @return
//     */
//    @Override
//    public List<ArticleCommentVo> getCommentContentByUserId(String userId) {
//        LambdaQueryWrapper<ArticleComment> eq = new LambdaQueryWrapper<ArticleComment>()
//                .eq(ArticleComment::getUserId, userId)
//                .eq(ArticleComment::getParentId, 0);
//        List<ArticleComment> list = this.list(eq);
//        return BeanUtil.copyToList(list, ArticleCommentVo.class);
//    }
//
////    /**
////     * 收到的评论列表
////     *
////     * @param userId
////     * @return
////     */
////    @Override
////    public List<CommentVo> commentList(String userId) {
////        List<CommentVo> commentVos = baseMapper.commentList(userId);
////        for (CommentVo vo : commentVos) {
////            MeltCloudUser user = userService.getById(vo.getUserId());
////            if (ObjectUtil.isNotEmpty(user)) {
////                vo.setUserName(user.getUserName());
////                vo.setUserPortrait(user.getUserPortrait());
////            }
////        }
////        return commentVos;
////    }
//
//    /**
//     * 发布评论
//     *
//     * @param commentDTO
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public void submit(ArticleCommentDTO commentDTO) {
//        ArticleComment comment = BeanUtil.copyProperties(commentDTO, ArticleComment.class);
//        this.save(comment);
//    }
}
